package controller

import (
	"hft/Database/admin"
	"hft/Http/Models/request"
	services "hft/Http/Services"
	utils "hft/Http/Utils"

	"github.com/gin-gonic/gin"
)

type CommonActivity struct{}

func (*CommonActivity) CreateActivity(c *gin.Context) {
	var data *admin.CommonActivity

	c.ShouldBindJSON(&data)

	err := services.CommonActivityService.CreateActivity(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*CommonActivity) EditActivity(c *gin.Context) {
	var data *admin.CommonActivity

	c.ShouldBindJSON(&data)

	err := services.CommonActivityService.EditActivity(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*CommonActivity) GetActivityList(c *gin.Context) {
	data, err := services.CommonActivityService.GetActivityList()

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(data, c)
}

func (*CommonActivity) Delete(c *gin.Context) {
	var ids *request.IDS
	c.ShouldBindJSON(&ids)
	if err := services.CommonActivityService.Delete(ids.IDS); err != nil {
		utils.FailWithMessage(err.Error(), c)
	} else {
		utils.Ok(c)
	}

}

var CommonActivityController = new(CommonActivity)
